use std::path::Path;

fn main() {
    let a = call_dynamic().unwrap();
    // let a = call_md5().unwrap();
    println!("{}", a);
}

fn call_dynamic() -> Result<i32, Box<dyn std::error::Error>> {
    unsafe {
        let lib_path = Path::new("libs/hgrs_codec.dll");
        let lib = libloading::Library::new(lib_path)?;
        let func: libloading::Symbol<unsafe extern fn(i32, i32) -> i32> = lib.get(b"add")?;
        
        let name = "hello world";
        let result = func(2, 5);
        
        Ok(result)
    }
}

/*fn call_md5() -> Result<String, Box<dyn std::error::Error>> {
    unsafe {
        let lib_path = Path::new("libs/hgrs_codec.dll");
        let lib = libloading::Library::new(lib_path)?;
        let func: libloading::Symbol<unsafe fn(&str) -> String> = lib.get(b"zip_utils::md5")?;

        let name = "hello world";
        let result = func(name);

        Ok(result)
    }
}*/
